import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/shared/util/util_mk.dart';
import 'package:bxultimate/widgets/mk_card_container.dart';
import 'package:bxultimate/widgets/mk_list_cell_item.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class OrganizationUserInformationPage extends StatefulWidget {
  const OrganizationUserInformationPage({Key? key}) : super(key: key);

  @override
  State<OrganizationUserInformationPage> createState() =>
      _OrganizationUserInformationPageState();
}

class _OrganizationUserInformationPageState
    extends State<OrganizationUserInformationPage> {
  final controller = Get.find<OrganizationUserInformationController>();
  final state = Get.find<OrganizationUserInformationController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
        child: Scaffold(
      backgroundColor: Colors.transparent,
      appBar: TDNavBar(
        title: '人员信息',
        backgroundColor: Colors.transparent,
      ),
      body: SingleChildScrollView(
        child: Obx(()=>_buildNav()),
      ),
    ));
  }

  _buildNav() {
    return MkCardContainer(
      padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding / 2),
      margin: EdgeInsets.all(AppTheme.iDefaultPadding),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          MkListCellItem(
            value: '姓名',
            ext: Text('${state.userInfo.name}'),
            rightIcon: SizedBox.shrink(),
            press: () {},
          ),
          MkListCellItem(
            value: '身份证号',
            ext: Text('${state.userInfo.idcard}'),
            rightIcon: SizedBox.shrink(),
            press: () {},
          ),
          MkListCellItem(
            value: '联系方式',
            ext: Text('${state.userInfo.phone}'),
            rightIcon: Icon(Icons.phone, color: Colors.blue),
            press: () async{
              await UtilMk.call(state.userInfo.phone!);
            },
          ),
          MkListCellItem(
            value: '服役信息',
            ext: Text('${state.userInfo.attendedInfo}'),
            rightIcon: SizedBox.shrink(),
            press: () {},
          ),
          MkListCellItem(
            value: '政治面貌',
            ext: Text('${state.userInfo.political}'),
            rightIcon: SizedBox.shrink(),
            press: () {},
          ),
          MkListCellItem(
            value: '所在队伍',
            ext: Text('${state.userInfo.belongTeam}'),
            rightIcon: SizedBox.shrink(),
            press: () {},
          ),
          MkListCellItem(
            value: '身份性质',
            ext: Text('${state.userInfo.roleName}'),
            rightIcon: SizedBox.shrink(),
            press: () {},
          ),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<OrganizationUserInformationController>();
    super.dispose();
  }
}
